package com.inspur.zhangpeixia.goods.utils;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

public class DBUtils {
    private static DataSource dataSource=null;
    static {
        try{
            Properties prop = new Properties();
            prop.load(DBUtils.class.getClassLoader().getResourceAsStream("druid.properties"));
            dataSource= DruidDataSourceFactory.createDataSource(prop);
        }catch (Exception e){
            throw  new RuntimeException(e);
        }

    }
    public static Connection getConnection(){
        try{
            return dataSource.getConnection();

        }catch (SQLException e){
            throw  new RuntimeException(e);
        }
    }
}
